/*
 Navicat Premium Data Transfer

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 50712
 Source Host           : localhost:3306
 Source Schema         : iw2ebetter
 Target Server Type    : MySQL
 Target Server Version : 50712
 File Encoding         : 65001

 Date: 20/07/2023 19:46:08
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for appraise_like
-- ----------------------------
CREATE DATABASE iw2ebetter;
USE iw2ebetter;
DROP TABLE IF EXISTS `appraise_like`;
CREATE TABLE `appraise_like` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `aid` int(11) NOT NULL COMMENT '点赞的点评id',
  `uid` int(11) NOT NULL COMMENT '点赞的用户id',
  `status` tinyint(1) DEFAULT '1' COMMENT '0表示未点赞，1表示点赞',
  PRIMARY KEY (`id`),
  KEY `idx_of_appraise_aid` (`aid`),
  KEY `idx_of_appraise_uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of appraise_like
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for appraises
-- ----------------------------
DROP TABLE IF EXISTS `appraises`;
CREATE TABLE `appraises` (
  `aid` int(11) NOT NULL AUTO_INCREMENT,
  `content` longtext CHARACTER SET utf8,
  `create_time` datetime NOT NULL,
  `available` tinyint(1) DEFAULT '0',
  `title` varchar(20) CHARACTER SET utf8 NOT NULL,
  `uid` int(11) DEFAULT NULL,
  `likes` int(11) DEFAULT '0',
  PRIMARY KEY (`aid`),
  KEY `appraises_ibfk_1` (`uid`),
  CONSTRAINT `appraises_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `users` (`uid`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of appraises
-- ----------------------------
BEGIN;
INSERT INTO `appraises` VALUES (1, '', '2023-07-20 19:18:46', 0, '很不错的啊', 1, 0);
COMMIT;

-- ----------------------------
-- Table structure for imgs
-- ----------------------------
DROP TABLE IF EXISTS `imgs`;
CREATE TABLE `imgs` (
  `iid` int(11) NOT NULL AUTO_INCREMENT,
  `src` varchar(256) DEFAULT '/images/photos/user.png',
  `aid` int(11) DEFAULT '0',
  PRIMARY KEY (`iid`),
  KEY `imgs_ibfk_1` (`aid`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of imgs
-- ----------------------------
BEGIN;
INSERT INTO `imgs` VALUES (1, '/images/appraise/10.', 1);
COMMIT;

-- ----------------------------
-- Table structure for responses
-- ----------------------------
DROP TABLE IF EXISTS `responses`;
CREATE TABLE `responses` (
  `reid` int(11) NOT NULL AUTO_INCREMENT,
  `content` varchar(1600) DEFAULT NULL,
  `response_time` datetime DEFAULT NULL,
  `aid` int(11) DEFAULT NULL,
  `available` tinyint(1) DEFAULT '0',
  `uid` int(11) DEFAULT NULL,
  PRIMARY KEY (`reid`),
  KEY `responses_ibfk_1` (`aid`),
  KEY `responses_ibfk_3` (`uid`),
  CONSTRAINT `responses_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `appraises` (`aid`) ON DELETE CASCADE,
  CONSTRAINT `responses_ibfk_3` FOREIGN KEY (`uid`) REFERENCES `users` (`uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of responses
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for roles
-- ----------------------------
DROP TABLE IF EXISTS `roles`;
CREATE TABLE `roles` (
  `rid` int(11) NOT NULL AUTO_INCREMENT,
  `role` varchar(256) NOT NULL,
  PRIMARY KEY (`rid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of roles
-- ----------------------------
BEGIN;
INSERT INTO `roles` VALUES (1, 'host');
INSERT INTO `roles` VALUES (2, 'admin');
INSERT INTO `roles` VALUES (3, 'user');
COMMIT;

-- ----------------------------
-- Table structure for user2role
-- ----------------------------
DROP TABLE IF EXISTS `user2role`;
CREATE TABLE `user2role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL,
  `rid` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of user2role
-- ----------------------------
BEGIN;
INSERT INTO `user2role` VALUES (1, 1, 3);
COMMIT;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `uid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户id',
  `username` varchar(50) NOT NULL COMMENT '用户名',
  `password` varchar(256) NOT NULL COMMENT '用户密码',
  `telephone` varchar(11) NOT NULL COMMENT '用户私人电话',
  `name` varchar(50) NOT NULL,
  `enable` tinyint(1) DEFAULT '1',
  `address` varchar(256) DEFAULT NULL,
  `src` varchar(256) DEFAULT '/images/photos/user.png' COMMENT '用户头像链接',
  PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of users
-- ----------------------------
BEGIN;
INSERT INTO `users` VALUES (1, 'mudaima', '$2a$10$1laK1NsFyoQ3QETSnHqWEu471DGusEYjErm/bZpwIheVT.d3N0cN2', '18819890000', 'mudaima', 1, '慕代码 www.mudaima.com', '/images/headImage/9d9d7ad.png');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
